<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center selectPost_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub selectPost_fd0_0'>
          <view class='flex flex-wrap align-center selectPost_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  selectPost_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='selectPost_fd0_0_c1_c0'>选择帖子</text>
          </view>
          <view class='flex flex-wrap align-center justify-end selectPost_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <view class="flex benben-position-layout flex flex-wrap align-center selectPost_flex_1"
        :style="{top:(88+StatusBarRpx)+'rpx', }">
        <view>
          <benben-flex-tabs class-name='selectPost_benbenTabsfd1_0' v-model="tabls" ref="benben_tabsfd1_0"
            select-mark="benben_tabsfd1_0" key="benben_tabsfd1_0" :open-title-type='false' :open-sticky='true' :top='0'
            :is-show-content='false' :scrollspy='false' :tabs-info.sync="tabsInfofd1_0" @change="checkSwitch()">

            <scroll-view @scroll="tabsInfofd1_0.scrollX = $event.detail.scrollLeft" id="benben_tabsfd1_0"
              class="benben-tabs" style="width:750rpx" :scroll-x="true" :scroll-left.sync="tabsInfofd1_0.moveX"
              scroll-with-animation="all .3s ease">
              <view class="benben-tabs-content" id="benben_tabsfd1_0-content">
                <view id="benben_tabsfd1_0-title" class="benben-tabs-title flex flex align-center justify-around">
                  <view :class="{ 'checkTitlefd1_0': tabls == '1', 'flex flex-wrap align-center': true }"
                    @tap="tabls = '1'" :id="`benben_tabsfd1_0-title-item-${'1'}`">

                    <text>过往发布</text>
                    <text v-if="dataInfo.fabu">({{dataInfo.fabu}})</text>

                  </view>
                  <view :class="{ 'checkTitlefd1_0': tabls == '2', 'flex flex-wrap align-center': true }"
                    @tap="tabls = '2'" :id="`benben_tabsfd1_0-title-item-${'2'}`">

                    <text>我的收藏</text>

                    <text v-if="dataInfo.shoucangjia">({{dataInfo.shoucangjia}})</text>

                  </view>
                </view>
                <view :style="{ left: tabsInfofd1_0.lineleft, maxWidth: tabsInfofd1_0.lineWidth ,}"
                  id="benben_tabsfd1_0-line" class="benben-tabs-line flex benben-flex-tabs-line selectPost_linefd1_0">
                </view>
              </view>
            </scroll-view>

          </benben-flex-tabs>

        </view>

      </view>
      <view :style="{height: '104rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout selectPost_flex_2">
        <view class='flex flex-wrap align-center selectPost_fd2_0'>
          <image class='selectPost_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"42.png"'></image>
          <benben-input class='flex-sub selectPost_fd2_0_c1' type="text" :placeholder="`搜索`" confirm-type="done"
            :maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx" v-model="keyworld"
            @confirm="switchDataFunc" />
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout selectPost_flex_3">
        <view ref="showSelectPopup1705117266845" class-name='flex flex-direction align-stretch flex'>
          <template v-for='(item,key0) in postList'>
            <view v-if="item.isSelected" class='flex flex-direction align-stretch flex selectPost_fd3_0_c0' :key="key0"
              @tap="chooseCheck(item,key0)">
              <view class='flex flex-wrap align-center justify-between'>
                <view class='text-cut-2 selectPost_fd3_0_c0_c0_c0' style="width: 550rpx;">{{item.title}}</view>
                <image class='selectPost_fd3_0_c0_c0_c1' mode="aspectFit" :src='STATIC_URL+"7.png"'></image>
              </view>
              <view class='flex flex-wrap align-center selectPost_fd3_0_c0_c1'>
                <text class='selectPost_fd3_0_c0_c1_c0'>{{item.content}}</text>
              </view>
              <view class='flex flex-wrap align-center selectPost_fd3_0_c0_c2'>
                <image class='selectPost_fd3_0_c0_c2_c0' mode="aspectFit" :src='item.avatar'></image>
                <text class='selectPost_fd3_0_c0_c2_c1'>{{item.user_nickname}}</text>
                <text class='selectPost_fd3_0_c0_c2_c2'>{{item.create_time}}</text>
                <text class='selectPost_fd3_0_c0_c2_c3' v-if=" item.is_arr==0">发布帖子</text><text
                  class='selectPost_fd3_0_c0_c2_c3' v-if=" item.is_arr=='1'">发布合集</text>
              </view>
            </view>

            <view v-else class='flex flex-direction align-stretch flex selectPost_fd3_0_c1' :key="key0"
              @tap="chooseCheck(item,key0)">
              <view class='flex flex-wrap align-center justify-between'>
                <!-- {{item}} -->
                <view class='text-cut-2 selectPost_fd3_0_c0_c0_c0' style="width: 550rpx;">{{item.title}}</view>
                <image class='selectPost_fd3_0_c0_c0_c1' mode="aspectFit" :src='STATIC_URL+"8.png"'></image>
              </view>
              <view class='flex flex-wrap align-center selectPost_fd3_0_c0_c1'>
                <text class='selectPost_fd3_0_c0_c1_c0'>{{item.content}}</text>
              </view>
              <view class='flex flex-wrap align-center selectPost_fd3_0_c0_c2'>
                <image class='selectPost_fd3_0_c0_c2_c0' mode="aspectFit" :src='item.avatar'></image>
                <text class='selectPost_fd3_0_c0_c2_c1'>{{item.user_nickname}}</text>
                <text class='selectPost_fd3_0_c0_c2_c2'>{{item.create_time}}</text>
                <text class='selectPost_fd3_0_c0_c2_c3' v-if=" item.is_arr==0">发布帖子</text><text
                  class='selectPost_fd3_0_c0_c2_c3' v-if=" item.is_arr=='1'">发布合集</text>
              </view>
            </view>
          </template>
          <fu-empty :pagingListLoadedAll="pagingListLoadedAll" :pagingListNoListData="pagingListNoListData"
            :listDataLength="listDataLength" :isLoadInit="isLoadInit"></fu-empty>
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->


      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex benben-flex-layout flex-wrap align-center selectPost_flex_5">
        <view class='flex flex-wrap align-center justify-center selectPost_fd5_0' @click.stop="throwClassificationFunc">
          <text class='selectPost_fd5_0_c0'>已选择({{post_arr.length}})</text>
          <!-- <text class='selectPost_fd5_0_c0'>1</text>
          <text class='selectPost_fd5_0_c0'>)</text> -->
        </view>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  import pagingList from '@/common/mixin/paging_list.js';
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},
    mixins: [pagingList],

    data() {
      return {
        "tabsInfofd1_0": {
          lineleft: '',
          lineWidth: '',
          moveX: 0,
          scrollX: 0,
          PageScrollX: 0
        },
        "minixPagingListsApi": "",
        "pageingListApiMethod": "",
        "allowOnloadGetList": false,
        "tabls": "1",
        "keyworld": "",
        "postsType": [{
          "name": "MOMO",
          "value": "1",
          "image": ""
        }, {
          "name": "KOKO",
          "value": "2",
          "image": ""
        }, {
          "name": "LOLO",
          "value": "3",
          "image": ""
        }],
        "posts_id": "",
        "dataInfo": {
          "invite_code": "",
          "address": "",
          "address_code": "",
          "hobby": "",
          "tags": "",
          "id": "",
          "userlevel_id": "",
          "mobile": "",
          "real_name": "",
          "avatar": "",
          "account": "",
          "email": "",
          "birthday": "",
          "gender": "",
          "create_time": "",
          "user_money": "",
          "freeze_money": "",
          "total_consumption_money": "",
          "score": "",
          "_mobile": "",
          "coupon": "",
          "collection_count": "",
          "browse_count": "",
          "total_money": "",
          "certified": "",
          "nickname": "",
          "is_pay_password": "",
          "follow_count": "",
          "is_close": "",
          "exp": "",
          "area_code": "",
          "jianjie": "",
          "level_name": "",
          "next_need_exp": "",
          "support_num": "",
          "follow_num": "",
          "fans_num": "",
          "user_label": [],
          "is_school": "",
          "fabu": "",
          "shoucangjia": ""
        },
        "postList": [],
        posts_name: '',
        "favoritesList": [],
        post_arr: [],
        post_arr_n: []
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      this.post_arr = JSON.parse(options.posts_id)
      this.posts_id = this.post_arr.map(item => {
        return item.aid
      }).join(',')
      console.log('pppp', this.post_arr, this.post_arr)
      this.getUserFunc()
      // this.getfavoritesFunc()
      this.switchDataFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {
      this.getfavoritesFunc()
      this.getPostsFunc()
    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      checkSwitch() {
        // this.post_arr = []
        // this.posts_id = ''
        this.getPostsFunc()
      },
      chooseCheck(item, index) {
        item.isSelected = !item.isSelected

        if (item.isSelected) {
          this.post_arr.push(item)
        } else {
          this.post_arr.splice(index, 1)
        }
        this.posts_id = this.post_arr.map(item => {
          return item.aid
        }).join(',')
        console.log('item.isSelected', this.post_arr)
        // this.post_arr = this.postList.filter(itemC => {
        //   return itemC.isSelected
        // })
      },
      throwClassificationFunc() {
        uni.$emit('tiezi', this.post_arr)
        this.$urouter.navigateBack(1);
      },
      //获取会员
      async getUserFunc() {
        //请求方法
        //数据验证

        let datadataInfo = await this.$api.get(global.apiUrls.post5c78c4772da97, {

        });

        if (datadataInfo.data.code != 1) {
          this.$message.info(datadataInfo.data.msg);
          return
        }
        let infodataInfo = datadataInfo.data;
        this.dataInfo = infodataInfo.data

      },
      //获取收藏夹
      getfavoritesFunc() {
        this.minixPagingListsApi = global.apiUrls.post657bce908b37a;
        this.pageingListApiMethod = 'post';
        this.allowOnloadGetList = false;
        this.pagingListPostDataContent = {
          type: '1',
          title: this.keyworld
        }
        this.listData = [];
        this.favoritesList = this.listData;
        this.pagingListToggle();

      },
      //获取帖子
      getPostsFunc() {

        let urls = ''
        if (this.tabls == 1) {
          urls = global.apiUrls.post657bb7cbed4f4
        } else {
          urls = global.apiUrls.post66026e477d1b6
        }
        this.minixPagingListsApi = urls;
        this.pageingListApiMethod = 'post';
        this.allowOnloadGetList = false;
        this.pagingListPostDataContent = {
          aid: this.posts_id
        }
        this.listData = [];
        this.postList = this.listData;


        this.pagingListToggle();

      },
      //切换数据
      switchDataFunc() {
        this.getPostsFunc()
        // if (this.tabls == '1') {
        //   this.getPostsFunc()
        // } else if (this.tabls == '2') {
        //   this.getfavoritesFunc()
        // }
      },
      pagingListPostData() {
        return this.pagingListPostDataContent

      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(248, 248, 248, 1);
    background-size: 100% auto;
  }

  .selectPost_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .selectPost_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .selectPost_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .selectPost_fd0_0_c0 {
    width: 120rpx;
  }

  .selectPost_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .selectPost_flex_1 {
    background: rgba(255, 255, 255, 1);
    width: 750rpx;
    height: 104rpx;
    overflow: hidden;
    z-index: 10;
    top: 88rpx;
    background-size: 100% auto;
  }

  .selectPost_linefd1_0 {
    background: rgba(100, 80, 235, 1);
    width: 80rpx;
    height: 6rpx;
    top: 80rpx;
    background-size: 100% auto !important;
    border-radius: 8rpx;
  }

  .checkTitlefd1_0 {
    font-weight: 700 !important;
    font-size: 28rpx !important;
    color: #333 !important;
    background-color: rgba(255, 255, 255, 1) !important;
  }

  ::v-deep .selectPost_benbenTabsfd1_0 {
    background: #fff;
    width: 750rpx;
    height: 90rpx;
    white-space: nowrap;
    text-align: center;
    font-size: 28rpx;
    font-weight: 400;
    color: #999999;
  }

  .selectPost_flex_2 {
    padding: 24rpx 32rpx 0rpx 32rpx;
  }

  .selectPost_fd2_0_c1 {
    color: #333;
    font-size: 28rpx;
  }

  .selectPost_fd2_0_c0 {
    width: 24rpx;
    height: 24rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 16rpx 0rpx 0rpx;
  }

  .selectPost_fd2_0 {
    background: rgba(255, 255, 255, 1);
    border-radius: 50rpx;
    background-size: 100% auto;
    padding: 16rpx 24rpx 16rpx 24rpx;
  }

  .selectPost_flex_3 {
    padding: 24rpx 32rpx 0rpx 32rpx;
  }

  .selectPost_fd3_0_c1 {
    background: rgba(255, 255, 255, 1);
    border-radius: 16rpx;
    background-size: 100% auto;
    padding: 32rpx 24rpx 32rpx 24rpx;
    margin: 0rpx 0rpx 24rpx 0rpx;
  }

  .selectPost_fd3_0_c0_c2_c3 {
    color: #999999;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .selectPost_fd3_0_c0_c2_c2 {
    color: #999999;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 32rpx;
    margin: 0rpx 17rpx 0rpx 0rpx;
  }

  .selectPost_fd3_0_c0_c2_c1 {
    color: #333333;
    font-size: 24rpx;
    font-weight: 700;
    line-height: 32rpx;
    margin: 0rpx 20rpx 0rpx 0rpx;
  }

  .selectPost_fd3_0_c0_c2_c0 {
    width: 48rpx;
    height: 48rpx;
    border-radius: 50%;
    margin: 0rpx 14rpx 0rpx 0rpx;
  }

  .selectPost_fd3_0_c0_c2 {
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .selectPost_fd3_0_c0_c1_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 44rpx;
    -webkit-line-clamp: 3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
  }

  .selectPost_fd3_0_c0_c1 {
    margin: 20rpx 0rpx 0rpx 0rpx;
  }

  .selectPost_fd3_0_c0_c0_c1 {
    width: 36rpx;
    height: 36rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .selectPost_fd3_0_c0_c0_c0 {
    color: #333333;
    font-size: 32rpx;
    font-weight: 700;
    line-height: 32rpx;
  }

  .selectPost_fd3_0_c0 {
    background: rgba(255, 255, 255, 1);
    padding: 32rpx 24rpx 32rpx 24rpx;
    border-radius: 16rpx;
    background-size: 100% auto;
    margin: 0rpx 0rpx 24rpx 0rpx;
  }

  .selectPost_flex_4 {
    padding: 24rpx 32rpx 0rpx 32rpx;
  }

  .selectPost_fd4_0_c4 {
    width: 14rpx;
    height: 26rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 0rpx auto;
  }

  .selectPost_fd4_0_c0 {
    color: #333333;
    font-size: 32rpx;
    font-weight: 700;
    line-height: 32rpx;
  }

  .selectPost_fd4_0 {
    background: rgba(255, 255, 255, 1);
    margin: 0rpx 0rpx 24rpx 0rpx;
    border-radius: 16rpx;
    background-size: 100% auto;
    padding: 32rpx 24rpx 32rpx 24rpx;
  }

  .selectPost_flex_5 {
    position: fixed;
    left: 215rpx;
    bottom: calc(64rpx + var(--window-bottom));
  }

  .selectPost_fd5_0_c0 {
    color: #FFFFFF;
    font-size: 32rpx;
    font-weight: 700;
    line-height: 32rpx;
  }

  .selectPost_fd5_0 {
    background: rgba(100, 80, 235, 1);
    border-radius: 44rpx;
    background-size: 100% auto;
    box-shadow: 0rpx 3rpx 6rpx 1rpx rgba(0, 0, 0, 0.08);
    width: 320rpx;
    height: 88rpx;
  }
</style>
